package com.example.administrator.myapplication;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

/**
 * Created by Administrator on 2016/11/17.
 */
public class anniu extends AppCompatActivity {
    MediaPlayer mediaPlayer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final Button bu = (Button)findViewById(R.id.button);
        final Button bu2 = (Button)findViewById(R.id.button2);
        final Button bu3 = (Button)findViewById(R.id.button3);
        final Button bu4 = (Button)findViewById(R.id.button4);
        final Button bu5 = (Button)findViewById(R.id.button5);
        final Button bu6 = (Button)findViewById(R.id.button6);
        final Button bu7 = (Button)findViewById(R.id.button7);
        final Button bu8 = (Button)findViewById(R.id.button8);
        final Button bu9 = (Button)findViewById(R.id.button9);

    bu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
           if (!mediaPlayer.isPlaying()){
                bu.setText("1");
               mediaPlayer.start();
           }
        }
    });

    bu2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu2.setText("2");
                mediaPlayer.start();
            }
        }
    });

    bu3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu3.setText("3");
                mediaPlayer.start();
            }
        }
    });

    bu4.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu4.setText("4");
                mediaPlayer.start();
            }
        }
    });

    bu5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(!mediaPlayer.isPlaying()){
                bu5.setText("5");
            }
        }
    });

    bu6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu6.setText("6");
            }
        }
    });

    bu7.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu7.setText("7");
            }
        }
    });

    bu8.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu8.setText("8");
            }
        }
    });

    bu9.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mediaPlayer.isPlaying()){
                bu9.setText("9");
            }
        }
    });
    }
}